package cn.itcast.Dao;

import cn.itcast.pojo.User;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@Component
public class UserDao {
    @Autowired
    private RestTemplate restTemplate;
@Autowired
private DiscoveryClient discoveryClient;// Eureka客户端，可以获取到服务实例信息

    public User queryUserById(Long id) {



        String url = "http://user-service/user/";

        return this.restTemplate.getForObject(url+id,User.class);
    }
}
